package sugarbind_input

class Disease {

    String disease_Name
	String disease_Ref

    static constraints = {
		disease_Name(blank:false,nullable:false)
		disease_Ref(nullable:true)	

		
		disease_Name(unique:true)
	}
	
	static hasMany = [disease_Synonyms:Disease_Synonym, disease_Area_Agents:Disease_Area_Agent, symptoms:Symptom]
	
	static mapping = {
//		id column: 'disease_id'
		id generator: 'sequence', params: [sequence: 'disease_id_seq']
		
		symptoms joinTable: [name: "disease_symptom", key: 'disease_id' ]
	}
	
	public String toString(){
		disease_Name + " (" + id +")" 
    }
	
	public static listDiseases()
	{
		Disease.list().sort{ it.toString(); }
	}
}
